package com.example.mobile2121606110syc0409homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Scanner;

public class MainActivity3 extends AppCompatActivity {

    private TextView tvMainTitle3;
    private TextView tvMainTit31;
    private TextView tvMainTit32;
    private TextView tvMainTit33;
    private EditText edtTtPN31;
    private Button btnMainjs3;
    private TextView tvMainTit34;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        initView();
        btnMainjs3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String txt = edtTtPN31.getText().toString();
                char s[] =txt.toCharArray();
                String c1 = null,c2 = null,c3 = null,c4 = null,c5 = null;
                for(int i = 0; i < s.length; i++){
                    char c = (char)(s[i]+4);
                    switch (i){
                        case 0:
                            c1 = String.valueOf(c);
                            break;
                        case 1:
                            c2 = String.valueOf(c);
                            break;
                        case 2:
                            c3 = String.valueOf(c);
                            break;
                        case 3:
                            c4 = String.valueOf(c);
                            break;
                        case 4:
                            c5 = String.valueOf(c);
                            break;
                    }
                }
                tvMainTit32.setText(c1+c2+c3+c4+c5);
            }
        });
    }

    private void initView() {
        tvMainTitle3 = (TextView) findViewById(R.id.tvMainTitle3);
        tvMainTit31 = (TextView) findViewById(R.id.tvMainTit31);
        tvMainTit32 = (TextView) findViewById(R.id.tvMainTit32);
        tvMainTit33 = (TextView) findViewById(R.id.tvMainTit33);
        edtTtPN31 = (EditText) findViewById(R.id.edtTtPN31);
        btnMainjs3 = (Button) findViewById(R.id.btnMainjs3);
        tvMainTit34 = (TextView) findViewById(R.id.tvMainTit34);
    }
}